package com.xique.door.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xique.door.bean.domain.VisitorDevice;
import com.xique.door.bean.request.device.DeviceDeleteRequest;
import com.xique.door.bean.request.visitor.VisitorAuthorizeListRequest;
import com.xique.door.mapper.VisitorDeviceMapper;
import com.xique.door.service.IVisitorDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shd
 * @create 2022/2/26 16:23
 */
@Service
public class VisitorDeviceServiceImpl extends ServiceImpl<VisitorDeviceMapper, VisitorDevice> implements IVisitorDeviceService {

    @Autowired
    private VisitorDeviceMapper visitorDeviceMapper;

    @Override
    public List<VisitorDevice> selectVisitorAuthorizeList(VisitorAuthorizeListRequest request) {
        request.setPageNum((request.getPageNum() - 1) * request.getPageSize());
        return visitorDeviceMapper.selectVisitorAuthorizeList(request);
    }

    @Override
    public int selectVisitorAuthorizeCount(VisitorAuthorizeListRequest request) {
        return visitorDeviceMapper.selectVisitorAuthorizeCount(request);
    }

    @Override
    public void deleteVisitorAuthorize(DeviceDeleteRequest request) {
        visitorDeviceMapper.deleteByVisitorId(request.getId());
    }


}
